package com.dces.jx.billtest.api.xwManageHistoricalState;
import com.dces.jx.billtest.dto.xwManageHistoricalState.DcDecLogDto;
import com.dces.jx.billtest.common.service.ExcelService;
import com.dces.jx.billtest.common.model.PCodeType;
import com.dces.jx.billtest.dto.xwManageHistoricalState.DcDecLogDto;
import com.dces.jx.billtest.dto.xwManageHistoricalState.DcDecLogParam;
import com.dces.jx.billtest.dto.xwManageHistoricalState.DcDecLogExportParam;
import com.dces.jx.billtest.xwManageHistoricalState.service.DcDecLogService;
import com.xdo.pcode.service.PCodeHolder;
import com.xdo.common.token.UserInfoToken;
import com.xdo.domain.PageParam;
import com.xdo.domain.ResultObject;
import com.xdo.springboot.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.net.URLEncoder;
import java.util.List;
/**
 * generated by Generate dc
 * 
 *
 * @author xdoV2.0
 * @date: 2021-9-10
 */
@RestController
@RequestMapping("v1/dcDecLog")
@Api(tags = "接口")
public class DcDecLogController extends BaseController {
    @Resource
    private DcDecLogService dcDecLogService;
    @Resource
    private PCodeHolder pCodeHolder;
    @Resource
    private ExcelService excelService;
    /**
     * @param dcDecLogParam
     * @param pageParam
     * @return
     */
    @ApiOperation("分页查询接口")
    @PostMapping("list")
    public ResultObject<List<DcDecLogDto>> getListPaged(@RequestBody DcDecLogParam dcDecLogParam, PageParam pageParam) {
        ResultObject<List<DcDecLogDto>> paged = dcDecLogService.selectAllPaged(dcDecLogParam, pageParam);
        return paged;
    }
    /**
     * @param dcDecLogParam
     * @param userInfo
     * @return
     */
    @ApiOperation("新增接口")
    @PostMapping()
    public ResultObject<DcDecLogDto> insert(@Valid @RequestBody DcDecLogParam dcDecLogParam, UserInfoToken userInfo) {
		ResultObject<DcDecLogDto> resultObject = ResultObject.createInstance(true, ResultObject.INSERT_SUCCESS);
        DcDecLogDto dcDecLogDto = dcDecLogService.insert(dcDecLogParam, userInfo);
        if (dcDecLogDto != null) {
            resultObject.setData(dcDecLogDto);
        } else {
            resultObject.setSuccess(false);
            resultObject.setMessage(ResultObject.INSERT_FAIL);
        }
        return resultObject;
    }
    /**
     * @param sid
     * @param dcDecLogParam
     * @param userInfo
     * @return
     */
    @ApiOperation("修改接口")
    @PutMapping("{sid}")
    public ResultObject<DcDecLogDto> update(@PathVariable String sid, @Valid @RequestBody DcDecLogParam dcDecLogParam, UserInfoToken userInfo) {
        dcDecLogParam.setSid(sid);
        DcDecLogDto dcDecLogDto = dcDecLogService.update(dcDecLogParam, userInfo);
        ResultObject resultObject = ResultObject.createInstance(true, ResultObject.UPDATE_SUCCESS);
        if (dcDecLogDto != null) {
            resultObject.setData(dcDecLogDto);
        } else {
            resultObject.setSuccess(false);
            resultObject.setMessage(ResultObject.UPDATE_FAIL);
        }
        return resultObject;
    }
    /**
     * @param sids
     * @return
     */
    @ApiOperation("删除接口")
    @DeleteMapping("{sids}")
    public ResultObject delete(@PathVariable List<String> sids, UserInfoToken userInfo) {
		ResultObject resultObject = ResultObject.createInstance(true, ResultObject.DELETE_SUCCESS);
        dcDecLogService.delete(sids, userInfo);
        return resultObject;
    }
}
